from asyncio import sleep

from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By

from net_project_page import NetProjectPage
from common.page import IOS, XPATH


class NetTingPage(NetProjectPage):
    not_submit = (IOS, 'type == "XCUIElementTypeStaticText" AND label == "已评课"')
    s = (XPATH, "//XCUIElementTypeButton[4]")
    comment_text = (XPATH, '//XCUIElementTypeStaticText[contains(@name,"请输入内容")]/../XCUIElementTypeTextView')
    def submit_Ting(self):
        self.find_element(*self.not_submit).click()
        self.find_static_text("查看详情").click()
        self.find_button(string="返回",contains_flag=1).click()
        self.find_button(string="去评课",contains_flag=1).click()
        self.find_static_text(string="请输入评价内容",contains_flag=1).click()
        # self.find_element(XPATH,'//XCUIElementTypeStaticText[contains(@label,"请输入内容")]').send_keys('课程评价内容显示展示展会较为加嘉禾哦我从事接我的我还崔欧文降低我女王武器哦和偶尔有发布重叠无哦车我共计搜初级电脑上传好的芜湖切换到五味欧恩')
        self.find_element(*self.comment_text).send_keys('课程评价内容显示展示展会较为加嘉禾哦我从事接我的我还崔欧文降低我女王武器哦和偶尔有发布重叠无哦车我共计搜初级电脑上传好的芜湖切换到五味欧恩')
        self.find_button("发布").click()
        sleep(2)
        self.find_static_text("去评价").click()
        self.find_element(By.XPATH, "//XCUIElementTypeCell[1]/XCUIElementTypeButton[4]").click()
        self.find_static_text("适度性").click()
        self.find_element(By.XPATH, "//XCUIElementTypeCell[2]/XCUIElementTypeButton[4]").click()
        self.find_static_text("结构性").click()
        self.find_element(By.XPATH, "//XCUIElementTypeCell[3]/XCUIElementTypeButton[4]").click()
        self.find_static_text("适用性").click()
        self.find_element(By.XPATH, "//XCUIElementTypeCell[4]/XCUIElementTypeButton[4]").click()
        self.find_static_text("整体性").click()
        self.find_element(By.XPATH, "//XCUIElementTypeCell[5]/XCUIElementTypeButton[4]").click()

        # j = 1
        # for s in range(12):
        #  try:
        #    if j<=12:
        #      self.get_frame_center_and_click(XPATH, "//XCUIElementTypeCell[j]/XCUIElementTypeButton[4]")
        #      j=j+1
        #  except NoSuchElementException:
        #      sleep(1)
        #      self.swipe_dr("up")
        #      continue
        #  else:
        #      break


        self.find_button("提交").click()
        sleep(3)
        self.swipe(21,23,21,23)
        self.find_button(string="分析报告", contains_flag=1).click()
        sleep(3)
        self.swipe_dr("down")
        self.find_button(string="返回",contains_flag=1).click()
        self.find_button(string="返回",contains_flag=1).click()
        self.find_button(string="返回",contains_flag=1).click()
        self.find_button("common back light icon").click()



